function menuwindow(title,url,w,h,menu){

    function bt_handler(url) {
        if (document.getElementById('CliNumero').value < 1) {
            Ext.getCmp('win-statusbar').setStatus({
                text: 'Tem de selecionar um cliente.'
            });
        } else {
            Ext.getCmp('win-statusbar').setStatus({
                text: 'Aguarde...'
            });
            document.pp_frm.action=url;
            subform('pp_frm','AppPool');
        }
    }
    subQur = new Ext.menu.Menu({
        id: 'subQur',
        items: [{
            text: 'Remessas',
            menu: new Ext.menu.Menu({
                items: [{
                    text: 'Operacao',
                    handler: function(){
                        idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=OR1',400,130);
                    }
                },{
                    text: 'Remessa',
                    handler: function(){
                        idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=OR2',400,130);
                    }
                },{
                    text: 'Cliente',
                    handler: function(){
                        idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=OR3',400,120);
                    }
                },{
                    text: 'Data',
                    handler: function(){
                        idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=OR4',400,120);
                    }
                },{
                    text: 'Beneficiario',
                    handler: function(){
                        idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=OR5',400,120);
                    }
                }]
            })
        },{
            text: 'Cliente',
            menu: [{
                text: 'Numero',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL1',400,130);
                }
            },{
                text: 'Nome',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL2',400,130);
                }
            },{
                text: 'Contacto',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL3',400,120);
                }
            },{
                text: 'Data de Nascimento',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL4',400,120);
                }
            },{
                text: 'Documento',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL5',400,120);
                }
            },{
                text: 'Numero de Beneficiario',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL6',400,120);
                }
            },{
                text: 'Nome de Beneficiario',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL7',400,120);
                }
            }]
        },{
            text: 'Beneficiario',
            menu: [{
                text: 'Numero',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=RC1',400,130);
                }
            },{
                text: 'Cliente',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=RC2',400,120);
                }
            },{
                text: 'Nome',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=RC3',400,130);
                }
            },{
                text: 'Contacto',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=RC4',400,120);
                }
            }]
        },{
            text: 'Conta',
            menu: [{
                text: 'Numero',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=AC1',400,130);
                }
            },{
                text: 'Beneficiario',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=AC2',400,130);
                }
            }]
        },{
            text: 'Deposito',
            menu: [{
                text: 'Data/Valor',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=DP1',400,130);
                }
            }]
        },{
            text: 'Exchange',
            menu: [{
                text: 'Operacao',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=EX1',400,130);
                }
            },{
                text: 'Remessa',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=EX2',400,130);
                }
            },{
                text: 'Cliente',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=EX3',400,120);
                }
            },{
                text: 'Data',
                handler: function(){
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=EX4',400,120);
                }
            }]
        }]
    });
    subActi = new Ext.menu.Menu({
        id: 'subActi',
        items: [{
            text: 'Duplicacao de Clientes',
            handler: function(){
                if(Ext.getCmp('ActiveOb').getText() != 'CL') {
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL1&ACT=1',400,130);
                } else {
                    document.pp_frm.action='_response/call.php?get=Operative/view/acti_CL_dup&OBJ='+Ext.getCmp('ActiveOb').getText()+'&SearchParam=CliNumero&SearchValue='+Ext.getCmp('ActiveObID').getText();
                    idtargetwindow('Duplicacao de Clientes','qwinResults','Wntargett',800,260);
                    subform('pp_frm','Wntargett');
                }
            }
        },{
            text: 'Bloquear/Desbloquer Cliente',
            handler: function(){
                if(Ext.getCmp('ActiveOb').getText() != 'CL') {
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=CL1&ACT=2',260,130);
                } else {
                    idwindow('Bloquear/Desbloquer Cliente','qwinResults','none','_response/call.php?get=Operative/view/acti_blk&OBJ='+Ext.getCmp('ActiveOb').getText()+'&SearchParam=CliNumero&SearchValue='+Ext.getCmp('ActiveObID').getText(),800,260);
                }
            }
        },{
            text: 'Bloquear/Desbloquer Remessa',
            handler: function(){
                if(Ext.getCmp('ActiveOb').getText() != 'OR') {
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=OR1&ACT=3',400,130);
                } else {
                    idwindow('Bloquear/Desbloquer Remessa','qwinResults','none','_response/call.php?get=Operative/view/acti_blkorder&OBJ='+Ext.getCmp('ActiveOb').getText()+'&SearchParam=FraID&SearchValue='+Ext.getCmp('ActiveObID').getText(),800,260);
                }
            }
        },{
            text: 'Cancelar Remessa',
            handler: function(){
                if(Ext.getCmp('ActiveOb').getText() != 'OR') {
                    idwindow('Pesquisa','src-window','none','_response/call.php?get=Operative/view/gridview&QID=OR1&ACT=4',400,130);
                } else {
                    idwindow('Cancelar Remessa','qwinResults','none','_response/call.php?get=Operative/view/acti_stchg&OBJ='+Ext.getCmp('ActiveOb').getText()+'&SearchParam=FraID&SearchValue='+Ext.getCmp('ActiveObID').getText(),800,260);
                }
            }
        }]
    });
    subNew = new Ext.menu.Menu({
        id: 'subNew',
        items: [{
            text: 'Envio',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/frm_OR&OR=0';
                subform('pp_frm','ORPanel');
                Ext.getCmp('ActiveObName').setText('NOVO ENVIO');
                Ext.getCmp('ActiveOb').setText('OR');
                Ext.getCmp('ActiveObID').setText(0);
            }
        },{
            text: 'Deposito',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/frm_DP&DP=0';
                subform('pp_frm','DPPanel');
                Ext.getCmp('ActiveObName').setText('NOVO DEPOSITO');
                Ext.getCmp('ActiveOb').setText('DP');
                Ext.getCmp('ActiveObID').setText(0);
            }
        },{
            text: 'Cliente',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/frm_CL&CL=0';
                subform('pp_frm','CLPanel');
                Ext.getCmp('ActiveObName').setText('NOVO CLIENTE');
                Ext.getCmp('ActiveOb').setText('CL');
                Ext.getCmp('ActiveObID').setText(0);
            }
        },{
            text: 'Documentos',
            handler: function(){
                if(Ext.getCmp('ActiveOb').getText() == 'CL') {
                    document.pp_frm.action='_response/call.php?get=Operative/view/frm_DC&DC=0&CL='+Ext.getCmp('ActiveObID').getText();
                    idtargetwindow('Documento de '+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'DCwin','DCPanel',800,260);
                    subform('pp_frm','DCPanel');
                    Ext.getCmp('ActiveObName').setText('NOVO DOCUMENTO');
                    Ext.getCmp('ActiveOb').setText('DC');
                    Ext.getCmp('ActiveObID').setText(0);
                } else {
                    Ext.getCmp('win-statusbar').setStatus({
                        text: 'Tem de Seleccionar um cliente.'
                    });
                }
            }
        },{
            text: 'Beneficiario',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/frm_RC?RC=0';
                subform('pp_frm','RCPanel');
                Ext.getCmp('ActiveObName').setText('NOVO BENEFICIARIO');
                Ext.getCmp('ActiveOb').setText('RC');
                Ext.getCmp('ActiveObID').setText(0);
            }
        },{
            text: 'Conta',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/frm_AC?AC=0';
                subform('pp_frm','ACPanel');
                Ext.getCmp('ActiveObName').setText('NOVA CONTA');
                Ext.getCmp('ActiveOb').setText('AC');
                Ext.getCmp('ActiveObID').setText(0);
            }
        }]
    });
    subDocs = new Ext.menu.Menu({
        id: 'subDocs',
        items: [{
            text: 'Importar do Ficheiro',
            handler: function(){}
        },{
            text: 'Enviar documento',
            handler: function(){}
        },{
            text: 'Digitalizar',
            handler: function(){}
        }]
    });

    subHist = new Ext.menu.Menu({
        id: 'subHist',
        items: [{
            text: 'Alteracoes',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/hst_CHG&'+Ext.getCmp('ActiveOb').getText()+'&'+Ext.getCmp('ActiveObID').getText();
                idtargetwindow('Alteracoes de&'+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'qwinResults','Wntargett',800,260);
                subform('pp_frm','Wntargett');
            }
        },{
            text: 'Bloqueios',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/hst_BLK&'+Ext.getCmp('ActiveOb').getText()+'&'+Ext.getCmp('ActiveObID').getText();
                idtargetwindow('Bloqueios de&'+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'qwinResults','Wntargett',800,260);
                subform('pp_frm','Wntargett');
            }
        },{
            text: 'Eventos',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/hst_EVT&'+Ext.getCmp('ActiveOb').getText()+'&'+Ext.getCmp('ActiveObID').getText();
                idtargetwindow('Eventos de&'+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'qwinResults','Wntargett',800,260);
                subform('pp_frm','Wntargett');
            }
        },{
            text: 'Actividades',
            handler: function(){
                document.pp_frm.action='_response/call.php?get=Operative/view/hst_ACT&'+Ext.getCmp('ActiveOb').getText()+'&'+Ext.getCmp('ActiveObID').getText();
                idtargetwindow('Actividades de&'+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'qwinResults','Wntargett',800,260);
                subform('pp_frm','Wntargett');
            }
        }]
    });

    subProper = new Ext.menu.Menu({
        id: 'subProper',
        items: [{
            text: 'Remessas',
            handler: function(){
                if (Ext.getCmp('ActiveOb').getText() == 'CL') {
                    document.pp_frm.action='_response/call.php?get=Operative/view/remittancegrid&OBJ=OR&SearchParam=FraCliNumero&SearchValue='+Ext.getCmp('ActiveObID').getText();
                    idtargetwindow('Remessas de&'+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'qwinResults','Wntargett',800,260);
                    subform('pp_frm','Wntargett');
                }
            }
        },{
            text: 'Documentos',
            handler: function(){
                if (Ext.getCmp('ActiveOb').getText() == 'CL') {
                    document.pp_frm.action='_response/call.php?get=Operative/view/remittancegrid&OBJ=DC&SearchParam=dtd_Cliente&SearchValue='+Ext.getCmp('ActiveObID').getText();
                    idtargetwindow('Documentos de&'+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'qwinResults','Wntargett',800,260);
                    subform('pp_frm','Wntargett');
                }
            }
        },{
            text: 'Beneficiarios',
            handler: function(){
                if (Ext.getCmp('ActiveOb').getText() == 'CL') {
                    document.pp_frm.action='_response/call.php?get=Operative/view/remittancegrid&OBJ=RC&SearchParam=uniCliente&SearchValue='+Ext.getCmp('ActiveObID').getText();
                    idtargetwindow('Beneficiarios de&'+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'qwinResults','Wntargett',800,260);
                    subform('pp_frm','Wntargett');
                }
            }
        },{
            text: 'Contas de Beneficiario',
            handler: function(){
                if (Ext.getCmp('ActiveOb').getText() == 'RC') {
                    document.pp_frm.action='_response/call.php?get=Operative/view/remittancegrid&OBJ=AC&SearchParam=cb_Beneficiario&SearchValue='+Ext.getCmp('ActiveObID').getText();
                    idtargetwindow('Contas de&'+Ext.getCmp('ActiveObName').getText()+'&'+Ext.getCmp('ActiveObID').getText(),'qwinResults','Wntargett',800,260);
                    subform('pp_frm','Wntargett');
                }
            }
        }]
    });

    subRepr = new Ext.menu.Menu({
        id: 'subRepr',
        items: [{
            text: 'detalhes das transaccoes',
            handler: function(){}
        },{
            text: 'formulario de conhecimento',
            handler: function(){}
        },{
            text: 'documentacao adicional',
            handler: function(){}
        }]
    });

    var MnMain = new Ext.Toolbar({
        height: 25,
        plain:true,
        items : [{
            text:'Buscas',
            menu: subQur
        },'-',{
            text:'Novo',
            menu: subNew
        },'-',{
            text:'Ações',
            menu: subActi
        },'-',{
            text:'Propriedades',
            menu: subProper
        },'-',{
            text:'Documentos',
            menu: subDocs
        },'-',{
            text:'Relatorios',
            menu: subRepr
        },'-',{
            text:'Historico',
            menu: subHist
        }
        ]
    });

    var properties = new Ext.Window({
        title:title,
        html : '<div id="ExecPanel"></div>',
        width:w,
        maximizable:true,
        height:h,
        resizable:false,
        items: [ MnMain ],
        bbar: new Ext.StatusBar({
            id: 'win-statusbar',
            defaultText: 'Pronto',
            items: ['-',{
                text: 'Seleccionado:'
            },{
                id: 'ActiveObName',
                type: 'text',
                text: ''
            },{
                id: 'ActiveOb',
                type: 'text',
                text: ''
            },{
                id: 'ActiveObID',
                type: 'text',
                width: 60,
                text: ''
            }, '-',{
                text: 'Imprimir',
                handler: function() {
                    replaceUrl('MX19Contents','');
                }
            }, '-',{
                text: 'Guardar',
                handler: function() {
                    Ext.getCmp('win-statusbar').setStatus({text: 'Em Execução...'});
                    document.pp_frm.action='_response/call.php?get=Operative/remittance&OBJ='+Ext.getCmp('ActiveOb').getText()+'&'+Ext.getCmp('ActiveOb').getText()+'='+Ext.getCmp('ActiveObID').getText();
                    subform('pp_frm','frm_Actions');

                }
            }, '-',
            new Date().format('d/n/Y'), ' ', ' ', '-', {
                xtype:'tbsplit',
                text:'Opções',
                menuAlign: 'br-tr?',
                menu: new Ext.menu.Menu({
                    items: [{
                        text: 'Item 1'
                    }, {
                        text: 'Item 2'
                    }]
                })
            }]
        })

    });
    properties.show();
    replaceUrl('ExecPanel',url);
}